package bean;

import java.io.Serializable;
import java.util.List;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table
@NamedQueries({
	@NamedQuery(name = "Departamento.findAll", query = "SELECT d FROM Departamento d"),
	@NamedQuery(name = "Departamento.findByIdeDep", query = "SELECT d FROM Departamento d WHERE d.ideDep = :ideDep"),
	@NamedQuery(name = "Departamento.findByNomDep", query = "SELECT d FROM Departamento d WHERE d.nomDep = :nomDep"),
	@NamedQuery(name = "Departamento.findByParteNomDep", query = "SELECT d FROM Departamento d WHERE d.nomDep like :nomDep"),
})
public class Departamento implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Basic(optional=false)
	@Column(name = "IdeDep")
	private Integer ideDep;
	@Column(name = "NomDep")
	private String nomDep;
	@Column(name = "TelDep")
	private String telDep;
	@OneToMany(cascade = CascadeType.ALL, mappedBy = "departamento")
	private List<Funcionario> funcionarios;
	
	public Departamento() {
		
	}

	public Integer getIdeDep() {
		return ideDep;
	}

	public void setIdeDep(Integer ideDep) {
		this.ideDep = ideDep;
	}

	public String getNomDep() {
		return nomDep;
	}

	public void setNomDep(String nomDep) {
		this.nomDep = nomDep;
	}

	public String getTelDep() {
		return telDep;
	}

	public void setTelDep(String telDep) {
		this.telDep = telDep;
	}

	public List<Funcionario> getFuncionarios() {
		return funcionarios;
	}

	public void setFuncionarios(List<Funcionario> funcionarios) {
		this.funcionarios = funcionarios;
	}
	@Override
	public int hashCode() {
		int hash = 0;
		hash += (ideDep != null ? ideDep.hashCode() : 0);
		return hash;
	}
	
	@Override
	public boolean equals(Object object) {
		if(!(object instanceof Departamento)) {
			return false;
		}
		
		Departamento other = (Departamento) object;
		if((this.ideDep == null && other.ideDep != null) || (this.ideDep != null && !this.ideDep.equals(other.ideDep))) {
			return false;
		}
		
		return true;
	}
	
	@Override
	public String toString() {
		return "bean.Departamento[ideDep=" + ideDep + "]";
	}
	
}
